# Contributor: Chloe Kudryavtsev <code@toast.bunkerlabs.net>
# Maintainer: Jakub Panek <me@panekj.dev>
pkgname=procs
pkgver=0.14.4
pkgrel=0
pkgdesc="Modern replacement for ps written in Rust"
url="https://github.com/dalance/procs"
arch="all"
license="MIT"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="procs-$pkgver.tar.gz::https://github.com/dalance/procs/archive/v$pkgver.tar.gz"

export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	# Default features enables "docker" feature that doubles the size of
	# the resulting binary with unnecessary bloat!
	cargo auditable build --release --frozen --no-default-features

	# generate shell completions
	target/release/procs --gen-completion bash
	target/release/procs --gen-completion fish
	target/release/procs --gen-completion zsh
}

check() {
	cargo test --frozen --no-default-features
}

package() {
	install -Dm755 target/release/procs "$pkgdir"/usr/bin/procs

	# install completions
	install -Dm644 procs.bash "$pkgdir"/usr/share/bash-completion/completions/procs
	install -Dm644 procs.fish "$pkgdir"/usr/share/fish/vendor_completions.d/procs.fish
	install -Dm644 _procs "$pkgdir"/usr/share/zsh/site-functions/_procs
}

sha512sums="
9af6b26749967ab79ed9025f78e6d83c2042a525799f851459a0d46fd92e2ed96a60db6371dce9969949679d998f4332ace6ba381867e414bf66a1e5d733fe60  procs-0.14.4.tar.gz
"
